﻿Object subclass: #Ejercicio17
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio17 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 23:10'!
iii
	Array compile: 'palindrome
		| mid len |
		len := self size.
		mid := ((len / 2) round: 0).
		1 to: mid do: [ :each | ((self at: each) = (self at: (len-each+1))) ifFalse: [ ^false. ]].
		^true.'! !

!Ejercicio17 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 23:00'!
i
	^Object subclasses size.! !

!Ejercicio17 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 23:02'!
ii
 ^ Smalltalk allClasses size.! !


Object subclass: #PluggableProxy
	instanceVariableNames: 'obj msg block'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!PluggableProxy methodsFor: 'as yet unclassified' stamp: 'ML 7/14/2015 11:17'!
doesNotUnderstand: aMsg
	^aMsg sendTo: obj.! !

!PluggableProxy methodsFor: 'as yet unclassified' stamp: 'ML 7/14/2015 11:23'!
of: anObj whenReceiving: aMsg doBefore: aBlock
	self class compile: ('{1} 
	{2} value.
	^{3} {1}.' format: {aMsg. aBlock. anObj.}).

	obj := anObj.
	msg := aMsg.
	block := aBlock.! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

PluggableProxy class
	instanceVariableNames: ''!

!PluggableProxy class methodsFor: 'as yet unclassified' stamp: 'ML 7/14/2015 10:50'!
of: anObj whenReceiving: aMsg doBefore: aBlock
	^self new of: anObj whenReceiving: aMsg doBefore:aBlock.! !


Object subclass: #Ejercicio08
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio08 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 20:17'!
foo: x
	| aBlock z y |
	z := 10.
	aBlock := [ x > 5 ifTrue: [ z := z + x. ^0 ] ifFalse: [ z := z -x. 5 ] ].
	y := aBlock value.
	y := y + z.
	^y.! !

!Ejercicio08 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 20:27'!
c
	" 0. Un bloque que hace return mata todo."
	^self foo: 10.! !

!Ejercicio08 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 20:22'!
a
	" 11. El bloque evalúa a falso, y devuelve 5. A z=10 se le restan 4 => y = 5+6."
	^self foo: 4.! !

!Ejercicio08 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 20:24'!
b
	" foo: 5 "
	^Message selector: #foo: argument: 5.! !


Object subclass: #Ejercicio09
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio09 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 20:50'!
a
	BlockClosure compile: 'curry
	(numArgs = 2) ifTrue: [^[:x | [:y | self value: x value: y.]]] ifFalse: [^false.].'.! !

!Ejercicio09 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 20:50'!
b
	BlockClosure compile: 'flip
	(numArgs = 2) ifTrue: [^[:x :y | self value: y value: x.]] ifFalse: [^false.].'.! !

!Ejercicio09 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 21:07'!
c
	Integer compile: 'timesRepeatPLP: aBlock
	(self > 0) ifTrue: [ aBlock value. (self-1) timesRepeatPLP: aBlock.]'! !


Object subclass: #Ejercicio05
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio05 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 15:58'!
c
	^ 3 factorialsList.! !

!Ejercicio05 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 15:56'!
enunciado
	Integer compile: ('factorialsList
	| list |
	list := OrderedCollection with: 1.
	2 to: self do: [ :aNumber | list add: (list last) * aNumber].
	^ list.').! !

!Ejercicio05 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 15:58'!
b
	" messageNotUnderstood. Es metodo de instancia, no de clase. "
	Integer factorialsList: 10.! !

!Ejercicio05 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 15:58'!
d
	^ 5 factorialsList at: 4.! !

!Ejercicio05 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 16:01'!
e
	" outOfBounds. "
	^ 5 factorialsList at: 6.! !

!Ejercicio05 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 15:56'!
a
	" Error. No hay nadie que reciba el mensaje. "! !


Object subclass: #Ejercicio02
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:20'!
a
	^(10 numberOfDigitsInBase: 2).! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:24'!
g
	^ 1@1 insideTriangle: 0@0 with: 2@0 with: 0@2.! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:24'!
f
	^1 = 2 ifTrue: [ 'what!!?' ].! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:25'!
h
	^ 'Hello World' indexOf: $o startingAt: 6.! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:32'!
i
	^ (OrderedCollection with: 1) add: 25; add: 35; yourself.! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:20'!
b
	^10 factorial.! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:21'!
d
	^ 20 + ( 3 * 5 ).! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:33'!
j
	Object subclass: #SnakesAndLadders
		instanceVariableNames: 'players square turn die over'
		classVariableNames: ''
		poolDictionaries: ''
		category: 'Snakesandladders'.! !

!Ejercicio02 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:21'!
c
	^20 + 3 * 5.! !


Object subclass: #Ejercicio07
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio07 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 16:08'!
aBis
	^ 'hola' magicMethod1.! !

!Ejercicio07 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 16:07'!
a
	" Es un reverse. Una instancia de String recibe el mensaje, y por cada uno de sus caracteres (self: do) lo agrega al principio de res (res := char, res -> la , concatena). "
	String compile: ('reverse
		|res|
		res := ''''.
		self do: [:char | res := char asString, res].
		^res.').! !

!Ejercicio07 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 16:13'!
b
	" Si existe x entre 2 y el predecesor del objeto receptor, tal que x es divisor, devuelve false. Si no, devuelve true. Es decir, 'esPrimo'."
	Integer compile: ('esPrimo
		self <= 1 ifTrue: [^false].
		2 to: (self-1) do: [ :each | (self \\ each = 0) ifTrue: [ ^false ] ].
	 	^ true.').! !


Object subclass: #Ejercicio11
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio11 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 22:48'!
i
	Collection compile: 'minConsidering: aBlock
	|minValue minElem|
	minElem := self at: 1.
	minValue := aBlock value: minElem.
	self do: [:each | |tmpVal| tmpVal := (aBlock value: each). 
										(tmpVal < minValue) 
											ifTrue: [ minValue := tmpVal ].
							].
	^ minValue.'! !

!Ejercicio11 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 22:47'!
ii
	Collection compile: 'closestTo: aPoint
	|minDist|
	minDist := self minConsidering: [ :p | (p dist: aPoint). ].
	^self select: [ :p | (p dist: aPoint) = minDist ].
	'.! !


Object subclass: #Ejercicio04
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:35'!
a
	^ [ :x | x + 1 ] value: 2.! !

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:43'!
g
	^ [ :x :y :z | x + y +z ] valueWithArguments: #(1 2 3).! !

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:42'!
f
	" Devuelve un bloque que le suma 1 a su parámetro. "
	^ [ [ :x | x +1 ] ] value.! !

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:44'!
h
	^ [ |z| z := 10. [ :x | x + z ] ] value value:10.! !

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:35'!
b
	^[ |x| x := 10. x + 12 ] value.! !

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:37'!
d
	" Error. Toma dos parámetros pero recibe 1. "
	^ [ :x :y | x + 1 ] value: 1.! !

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:38'!
e
	" Un bloque que devuelve 3 sin importar su parámetro. "
	^ [ :x | [ :y | x + 1 ] ] value: 2.! !

!Ejercicio04 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 14:36'!
c
	^ [ :x :y | |z| z := x + y ] value: 1 value: 2.! !


Object subclass: #Ejercicio10
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'PLP-PrVIII'!

!Ejercicio10 methodsFor: 'as yet unclassified' stamp: 'ML 7/13/2015 22:28'!
enunciado
	BlockClosure class compile: 'generarBloqueInfinito
	| x |
	x := 0.
	^[ x := x + 1. (Array with: x with: thisContext closure).].'! !
